<template>
 <a-button type="primary" @click="btnClick">打开模态框</a-button>
<modal-comp ref="customModal"></modal-comp>
</template>


<script setup lang="ts">
import { ref, onMounted } from 'vue';
import  ModalComp  from './components/ModalComp.vue';

// InstanceType<typeof ModalComp>>可以得到ModalComp子类的
// 实例对象类型
const customModal = ref<InstanceType<typeof ModalComp>>();
const btnClick = ():void => {
    customModal.value?.showModal(true);
}

onMounted(() => {
  // 另外提一句
  // 在onMounted钩子中才能拿到ModalComp实例对象
  console.log(customModal.value);
});
</script>


<style></style>